﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DPS.Prototype.Model;
using DPS.Prototype.Log;
using DPS.Prototype.Extension;
using DPS.Prototype.PolicyBase.Manager;

namespace DPS.Prototype.PolicyBase.Tracking
{
    internal class FileTracking:ITracking
    {
        FileLog log;
        private string cycleSplitLine = "***************************************************************************************************";
        internal FileTracking()
        {
            log = new FileLog();
        }
        public void TrackingStartingBatch()
        {
            string benginContent = string.Format("Start new batch:{0}", CurrentPolicyMaker.CurrentBatchId);
           log.Log(benginContent, CurrentPolicyMaker.CurrentBatchId);
        }

        public void TrackingStartingNewCycle()
        {
            string benginContent = string.Format("{0}\nStart new Cycle:{1}", this.cycleSplitLine,CurrentPolicyMaker.CurrentCycle);
            log.Log(benginContent, CurrentPolicyMaker.CurrentBatchId);
        }

        public void TrackingEndingBatch()
        {
            string benginContent = string.Format("End batch:{0}", CurrentPolicyMaker.CurrentBatchId);
            log.Log(benginContent, CurrentPolicyMaker.CurrentBatchId);
        }

        public void TrackingEndingNewCycle()
        {
            string benginContent = string.Format("\nEnd Cycle:{0}", CurrentPolicyMaker.CurrentCycle);
            log.Log(benginContent, CurrentPolicyMaker.CurrentBatchId);
        }

        public void TrackingReceivingNewSubMission(Submission submission)
        {
            string content = string.Format("Receiving new Submisson From{0},the Content is:\n{1}",submission.ProdCompetitorName,submission.Inspect());
            log.Log(content, CurrentPolicyMaker.CurrentBatchId);
        }

        public void TrackingMakingPolicy(List<PolicyOrder> policyorders)
        {
            string content = string.Format("The Policy maker made policy,as :{0}",policyorders.Inspect());
            log.Log(content, CurrentPolicyMaker.CurrentBatchId);
        }

        public void TrackingReceivingPolicy(PolicyOrder policyOrder, ProdCompetitorBase prodCompetitor)
        {
            string content = string.Format("The ProdCompetitor received order from policy meker,as :{0}", policyOrder.Inspect());
            log.Log(content, CurrentPolicyMaker.CurrentBatchId);
        }

        public void TrackingSubmitOccupy(SubmitResult submitResult)
        {
             string content = string.Format("The ProdCompetitor{0} submit occupy result,as :{1}", submitResult.Inspect());
            log.Log(content, CurrentPolicyMaker.CurrentBatchId);
        }


        private PolicyMakerBase CurrentPolicyMaker
        {
            get
            {
                return PolicyMakerManager.Current.PolicyMaker;
            }
        }

        
    }
}
